package org.fall.service.ipml;

import org.fall.entity.po.MemberPO;
import org.fall.entity.po.MemberPOExample;
import org.fall.mapper.MemberPOMapper;
import org.fall.service.api.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(readOnly = true)
@Service
public class MemberServiceImpl implements MemberService{
    @Autowired
    private MemberPOMapper memberPOMapper;

    @Override
    public MemberPO getMemberPOByLoginAcct(String loginacct) {
        MemberPOExample example = new MemberPOExample();
        MemberPOExample.Criteria criteria = example.createCriteria();
        //封装查询条件
        criteria.andLoginacctEqualTo(loginacct);
        List<MemberPO> list = memberPOMapper.selectByExample(example);
        return list.get(0);
    }

    @Transactional(propagation =  Propagation.REQUIRES_NEW,
    rollbackFor = Exception.class,
            readOnly = false
    )
    @Override
    public void saveMember(MemberPO memberPO) {
        memberPOMapper.insertSelective(memberPO);
    }
}
